package com.changan.controller;

import com.changan.entity.Menu;
import com.changan.response.Result;
import com.changan.service.MenuService;
import com.changan.vo.MenuVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author NieChangan
 * @since 2025-09-03
 */
@CrossOrigin
@Tag(name = "菜单管理")
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Resource
    private MenuService menuService;

    @Operation(summary = "加载菜单树", description = "获取所有菜单树，以及展开项")
    @GetMapping("/tree")
    public Result tree(){
        //通过递归查询所有菜单树
        List<MenuVO> menuTree = menuService.findMenuTree();
        return Result.ok().data("menuTree",menuTree);
    }
}
